from common.ReadBaseExcel import ReadBaseExcel


class LoginData:
    #获取用户登录账号
    def ReadAuthExcel(self):
        UserAccount = ReadBaseExcel().Read_excel('/dataSource/auth_information.xls')
        for i in UserAccount:
            Run = i.get('Run')
            grant_type = i.get('grant_type')
            username ='+' + str(i.get('username'))
            password = i.get('password')
            scope = i.get('scope')
            access_token_manager_id =i.get('access_token_manager_id')
            Authorization = i.get('authorization')
            AuthMethod = i.get('method')
            request = i.get('request')
            host = i.get('host')
            path = i.get('path')
            if Run.lower() == 'r':
                Account = dict()
                Account['grant_type'] = grant_type
                Account['username'] = username
                Account['password'] = password
                Account['scope'] = scope
                Account['access_token_manager_id'] = access_token_manager_id
                AuthURL = request + '://'+ host + path
                return Account, Authorization, AuthMethod, AuthURL



    #获取登录信息
    def ReadAppTokenPathExcel(self):
        ApptokenURL = ReadBaseExcel().Read_excel('/dataSource/apptokenpath.xls')
        for i in ApptokenURL:
            Run = i.get('Run')
            request = i.get('request')
            host = i.get('host')
            path = i.get('path')
            LoginMethod = i.get('method')
            Content_Type = i.get('Content_Type')
            appVersion = i.get('appVersion')
            os = i.get('os')
            smDeviceId = i.get('smDeviceId')
            # LoginURL = request + '://' + host + path
            if Run.lower() == 'r':
                return path,LoginMethod,Content_Type,appVersion,os,smDeviceId

if __name__ == '__main__':
    ReadExcel = LoginData()
    Account,Authorization,method,AuthURL =ReadExcel.ReadAuthExcel()
    print(Account)
    print(Authorization)
    print(method)
    print(AuthURL)
    URL,method1,Content_Type,appVersion,os,smDeviceId = ReadExcel.ReadAppTokenPathExcel()
    print(URL)
    print(method1)
    print(Content_Type)
    print(appVersion)
    print(os)
    print(smDeviceId)